

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
    <style>
    /* base */
    html,
    body,
    .container {
      width: 100%;
      height: 100%;
    }

    a,
    a:link,
    a:visited {
      text-decoration: none;
      color: inherit;
    }

    ul {
      list-style: none;
    }

    *,
    ::before,
    ::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    *:focus {
      outline: 0;
    }

    .container {
      display: flex;
      padding-top: 20px;
    }

    /* Nav */
    .container .doc-nav {
      position: fixed;
      height: 100%;
      margin: 0 30px 0 40px;
      width: 280px;
    }

    .doc-nav .nav-header {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      background-color: rgb(240, 241, 242);
      height: 40px;
      padding: 16px;
      font-size: 18px;
      font-weight: 500;
      color: rgb(62, 64, 66);
      cursor: pointer;
    }

    .doc-nav .nav-content {
      height: calc(100% - 40px);
      overflow-y: auto;
      color: rgb(32, 34, 36);
    }

    .doc-nav .nav-content .nav-list,
    .doc-nav .nav-content .nav-sub-list {
      line-height: 1.5rem;
    }

    .doc-nav .nav-content .nav-label {
      display: inline-block;
      position: relative;
      padding: 2px 0 2px 20px;
      margin-bottom: 4px;
    }

    .doc-nav .nav-content .nav-sub-label {
      position: relative;
      padding: 2px 0 2px 40px;
      font-size: 14px;
    }

    .doc-nav .nav-content .nav-sub-label:hover {
      text-decoration: underline;
    }

    .doc-nav .nav-content .nav-list .nav-label.group::before {
      border-bottom: 0.25rem solid transparent;
      border-left: 0.25rem solid #6e7072;
      border-right: 0;
      border-top: 0.25rem solid transparent;
      content: '';
      display: block;
      height: 0;
      left: 0.5rem;
      position: absolute;
      top: 0.625rem;
      transition: transform 0.1s linear;
      width: 0;
    }

    .doc-nav .nav-content .nav-list .nav-label.group.active::before {
      transform: rotate(90deg);
    }

    /* doc content */
    .container .doc-content {
      position: fixed;
      height: 100%;
      width: calc(100% - 80px - 40px - 30px - 240px);
      right: 0%;
      overflow-y: auto;
    }

    .doc-title {
      border-bottom: 1px solid #dcdee0;
      font-size: 22px;
      margin: 8px 0 0;
      padding-bottom: 16px;
    }

    .doc-content h3 {
      font-size: 24px;
      font-weight: 600;
      margin: 24px 0;
    }

    .doc-content h4 {
      font-size: 22px;
      font-weight: 500;
      margin: 30px 0 8px;
    }

    .doc-content h4 span {
      color: #007d9c;
    }

    .doc-content .doc-declare {
      background-color: #fafafa;
      border-radius: 5px;
      border: 1px solid #ccc;
      font-size: 14px;
      overflow-x: auto;
      padding: 10px;
      tab-size: 4;
      line-height: 20px;
    }

    .doc-content .doc-comment {
      font-size: 16px;
      margin: 16px 0;
      line-height: 24px;
      word-break: break-word;
    }
  </style>

</head>
<body>
  <div class="container">
    <div class="doc-nav">
      <a href="#Documentation" class="nav-header">Documentation</a>
      <nav class="nav-content">
        <ul class="nav-list">
          <li>
            <a href="#includes" class="nav-label">Includes</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#stdint.h" class="nav-sub-label">stdint.h</a>
              </li>
      

              <li>
                <a href="#tuya_cloud_types.h" class="nav-sub-label">tuya_cloud_types.h</a>
              </li>
      

              <li>
                <a href="#tuya_pin.h" class="nav-sub-label">tuya_pin.h</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#macros" class="nav-label">Macros</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#__TUYA_KEY_H" class="nav-sub-label">__TUYA_KEY_H</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#functions" class="nav-label">Functions</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#reg_proc_key" class="nav-sub-label">reg_proc_key</a>
              </li>
      

              <li>
                <a href="#key_init" class="nav-sub-label">key_init</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#vars" class="nav-label">Vars</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#consts" class="nav-label">Consts</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#types" class="nav-label">Types</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#typedefs" class="nav-label">Typedefs</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#PUSH_KEY_TYPE_E;
" class="nav-sub-label">PUSH_KEY_TYPE_E;
</a>
              </li>
      

              <li>
                <a href="#KEY_LONG_PRESS_TP_E;
" class="nav-sub-label">KEY_LONG_PRESS_TP_E;
</a>
              </li>
      

              <li>
                <a href="#VOID" class="nav-sub-label">VOID</a>
              </li>
      

              <li>
                <a href="#KEY_USER_DEF_S;
" class="nav-sub-label">KEY_USER_DEF_S;
</a>
              </li>
      
            </ul>
            
          </li>
        </ul>
      </nav>
    </div>
    <div class="doc-content">
      <h2 id="Documentation" class="doc-title">Documentation</h2>
      <h3 id="includes">Includes</h3>
      

      <h4 id="stdint.h"><span>stdint.h</span></h4>
      <pre class="doc-declare"><code>#include &lt;stdint.h&gt;
</code></pre>
      <pre class="doc-comment">#include <stdint.h>
</pre>

      <h4 id="tuya_cloud_types.h"><span>tuya_cloud_types.h</span></h4>
      <pre class="doc-declare"><code>#include "tuya_cloud_types.h"
</code></pre>
      <pre class="doc-comment">#include "tuya_cloud_types.h"
</pre>

      <h4 id="tuya_pin.h"><span>tuya_pin.h</span></h4>
      <pre class="doc-declare"><code>#include "tuya_pin.h"
</code></pre>
      <pre class="doc-comment">#include "tuya_pin.h"
</pre>
      <h3 id="macros">Macros</h3>
      

      <h4 id="__TUYA_KEY_H">Marco <span>__TUYA_KEY_H</span></h4>
      <pre class="doc-declare"><code>#define __TUYA_KEY_H
</code></pre>
      <pre class="doc-comment"></pre>
      <h3 id="functions">Functions</h3>
      

      <h4 id="reg_proc_key">Func <span>reg_proc_key</span></h4>
      <pre class="doc-declare"><code>OPERATE_RET reg_proc_key(IN CONST KEY_USER_DEF_S *key_ud);</code></pre>
      <pre class="doc-comment">/**
 * @brief Register a new KEY
 * 
 * @param[in] key_ud User defined key, see KEY_USER_DEF_S
 * 
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */</pre>

      <h4 id="key_init">Func <span>key_init</span></h4>
      <pre class="doc-declare"><code>OPERATE_RET key_init(IN CONST KEY_USER_DEF_S *p_tbl,IN CONST INT_T cnt,\
                        IN CONST INT_T timer_space);</code></pre>
      <pre class="doc-comment">/**
 * @brief Initialize KEY process service
 * 
 * @param[in] p_tbl User defined key tables, see KEY_USER_DEF_S
 * @param[in] cnt Count of key tables
 * @param[in] timer_space Key detect interval (unit ms). No more than 100,
 * if 0 then use default value(20ms)
 * 
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */</pre>
      <h3 id="vars">Vars</h3>
      
      <h3 id="consts">Consts</h3>
      
      <h3 id="types">Types</h3>
      
      <h3 id="typedefs">Typedefs</h3>
      

      <h4 id="PUSH_KEY_TYPE_E;
">Typedef <span>PUSH_KEY_TYPE_E;
</span></h4>
      <pre class="doc-declare"><code>typedef enum {
   /** one shot */
   NORMAL_KEY = 0,
   /** continual shot */
   SEQ_KEY,
   /** long press */
   LONG_KEY,
}PUSH_KEY_TYPE_E;
</code></pre>
      <pre class="doc-comment">/**
 * @brief Definition of KEY type
 */</pre>

      <h4 id="KEY_LONG_PRESS_TP_E;
">Typedef <span>KEY_LONG_PRESS_TP_E;
</span></h4>
      <pre class="doc-declare"><code>typedef enum {
   /** long press invalid */
   LP_INVALID = 0,
   /** long press once trigger */
   LP_ONCE_TRIG,
   /** long press more normal trigger */
   LP_MORE_NORMAL_TRIG,
   /** press key immedialtely trigger */
   FALLING_EDGE_TRIG,
   /** press key immedialtely trigger & LONG */
   FALLING_LONG_TRIG,
}KEY_LONG_PRESS_TP_E;
</code></pre>
      <pre class="doc-comment">/**
 * Definitioin of long pross type
 */</pre>

      <h4 id="VOID">Typedef <span>VOID</span></h4>
      <pre class="doc-declare"><code>typedef VOID(* KEY_CALLBACK)(tuya_pin_name_t port,PUSH_KEY_TYPE_E type,INT_T cnt);
</code></pre>
      <pre class="doc-comment">/**
 * @brief Handler of KEY event
 * 
 * @param[in] port PIN ID that got the event
 * @param[in] type Press type, see PUSH_KEY_TYPE_E
 * @param[in] cnt Count of continual. 
 * 
 * @note (cnt >= 2) ==> SEQ_KEY,
 * time < long_key_time && (cnt == 1) ==> NORMAL_KEY,
 * time >= long_key_time && (cnt == 1) ==> LONG_KEY
 */</pre>

      <h4 id="KEY_USER_DEF_S;
">Typedef <span>KEY_USER_DEF_S;
</span></h4>
      <pre class="doc-declare"><code>typedef struct {
   /** PIN ID */
   tuya_pin_name_t port;
   /** whether low level trigger */
   BOOL_T low_level_detect;
   /** long press type, see KEY_LONG_PRESS_TP_E */
   KEY_LONG_PRESS_TP_E lp_tp;
   /** unit: ms, lp_tp == LP_ONCE_TRIG then valid and must >= 1000ms */
   USHORT_T long_key_time;
   /** unit:ms , 0:disable default:400ms */
   USHORT_T seq_key_detect_time;
   /** handler of KEY event */
   KEY_CALLBACK call_back;
}KEY_USER_DEF_S;
</code></pre>
      <pre class="doc-comment">/**
 * @brief Definition of user defined key
 */</pre>
    </div>
  </body>
</html>
            